<!DOCTYPE HTML>
<html lang="en">
    <head>
        <title>Hyphenator.js &ndash; Test 108</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <style type="text/css">
            body {
                width:50%;
                margin-left:25%;
                margin-right:25%;
            }
            textarea {
                font-family: monospace;
            }
            #test1, #test2 {
                background-color: #ffd6d6;
            }
            #ref {
                background-color: #d6ffd6;
            }
        </style>
        <script src="../Hyphenator.js" type="text/javascript"></script>
        <script src="../patterns/en-us.js" type="text/javascript"></script>
        <script type="text/javascript">
                Hyphenator.config({
                    hyphenchar:'|',
                    enablereducedpatternset: true
                });
                function process() {
                    var rps, pat, space, divider, s, hyphenated = Hyphenator.hyphenate(document.getElementById('ta1').value, 'en');
                    s = hyphenated + '\n\n';
                    rps = Hyphenator.getRedPatternSet('en');
                    for (pat in rps) {
                        if (rps.hasOwnProperty(pat)) {
                            space = 12 - pat.length;
                            divider = '';
                            while (space !==0) {
                                divider += ' ';
                                space -= 1;
                            }
                            divider += ':';

                            s += pat + divider + rps[pat] + '\n';
                        }
                    }
                    document.getElementById('ta2').value = s;
                }
                
                window.onload = function() {
                    document.getElementById('ta1').onchange = process;
                    if (window != parent) {
                        document.getElementById('ta1').value = "Hyphenation";
                        document.getElementById('ta1').onchange();
                        window.setTimeout(function () {
                            var t1 = document.getElementById('ta2').value,
                            t2 = 'Hy|phen|ation\n\nhyph        :hy3ph\nhen         :he2n\nhena        :hena4\nhenat       :hen5at\nna          :1na\nnat         :n2at\ntio         :1tio\nio          :2io\non          :o2n\n',
                            desc = document.getElementById('desc').firstChild.data,
                            msg = {
                                desc: desc,
                                index: 108
                            };
                            if (t1 == t2) {
                                msg.result = 'passed';
                            } else {
                                msg.result = 'failed';
                            }
                            parent.postMessage(JSON.stringify(msg), window.location.href);
                        }, 200);
                    };
                }
        </script>
    </head>
    <body>
        <p><a href="index.html">&lt;&lt;- index</a> | <a href="test107.html">&lt;- Prev</a> | <a href="test109.html">Next -&gt;</a></p>
        <h1>Test 108</h1>
        <p id="desc">Get reduced pattern set: type english words in the upper box!</p>
        <div><textarea cols="20" rows="3" id="ta1"></textarea></div>
        <div><textarea cols="40" rows="30" id="ta2"></textarea></div>
    </body>
</html>